API * better profiler modules naming
authorYuri Astrakhan <yurik@users.mediawiki.org>
Mon, 16 Oct 2006 23:25:51 +0000 (23:25 +0000)
committerYuri Astrakhan <yurik@users.mediawiki.org>
Mon, 16 Oct 2006 23:25:51 +0000 (23:25 +0000)
includes/api/ApiBase.php

index 466e25e..8e1974b 100644 (file)
@@ -52,12 +52,22 @@ abstract class ApiBase {
        public abstract function execute();
 
     /**
-     * Get the name of the query being executed by this instance 
+     * Get the name of the module being executed by this instance 
      */
     public function getModuleName() {
         return $this->mModuleName;
     }
 
+    /**
+     * Get the name of the module as shown in the profiler log 
+     */
+    public function getModuleProfileName($db = false) {
+        if ($db)
+            return 'API:' . $this->mModuleName . '-DB';
+        else
+               return 'API:' . $this->mModuleName;
+    }
+
        /**
         * Get main module
         */
@@ -394,7 +404,7 @@ abstract class ApiBase {
                if ($this->mTimeIn !== 0)
                        ApiBase :: dieDebug(__METHOD__, 'called twice without calling profileOut()');
                $this->mTimeIn = microtime(true);
-               wfProfileIn($this->getModuleName()); 
+               wfProfileIn($this->getModuleProfileName());
        }
 
        /**
@@ -408,7 +418,7 @@ abstract class ApiBase {
 
                $this->mModuleTime += microtime(true) - $this->mTimeIn;
                $this->mTimeIn = 0;
-               wfProfileOut($this->getModuleName()); 
+               wfProfileOut($this->getModuleProfileName()); 
        }
 
        /**
@@ -434,7 +444,7 @@ abstract class ApiBase {
                if ($this->mDBTimeIn !== 0)
                        ApiBase :: dieDebug(__METHOD__, 'called twice without calling profileDBOut()');
                $this->mDBTimeIn = microtime(true);
-               wfProfileIn($this->getModuleName() . '_db');
+               wfProfileIn($this->getModuleProfileName(true));
        }
 
        /**
@@ -451,7 +461,7 @@ abstract class ApiBase {
 
                $this->mDBTime += $time;
                $this->getMain()->mDBTime += $time;
-               wfProfileOut($this->getModuleName() . '_db');
+               wfProfileOut($this->getModuleProfileName(true));
        }
 
        /**